package com.md24housecall.adapter;
 
import java.util.ArrayList;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.md24housecall.model.TagCategory;

public class MainAdapter extends BaseAdapter {
//	private Context context;
	private ArrayList<TagCategory> mItems;
	

	public MainAdapter(Context context, ArrayList<TagCategory> items) {
//		this.context = context;
		mItems = items;
		if(mItems == null)
			mItems = new ArrayList<TagCategory>();
		
	}
	
	
	public void updateAdapter(ArrayList<TagCategory> items) {
		mItems = items;
		if(mItems == null)
			mItems = new ArrayList<TagCategory>();
		notifyDataSetChanged();
	}
	
	public void resetAdapter() {
		mItems.clear();
		notifyDataSetChanged();
	}
	
	public ArrayList<TagCategory> getData() {
		return mItems;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		/*HolderCategory holder = null;

		LayoutInflater mInflater = (LayoutInflater) context
				.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
		if (convertView == null) {
			holder = new HolderCategory();
			convertView = mInflater.inflate(holder.getLayoutId(), null);
			holder.initView(convertView);
			convertView.setTag(holder);
		} else {
			holder = (HolderCategory) convertView.getTag();
		}

		TagCategory rowItem = (TagCategory) getItem(position);
		holder.updateData(rowItem);*/

		return convertView;
	}

	@Override
	public int getCount() {
		return mItems.size();
	}

	@Override
	public Object getItem(int position) {
		return mItems.get(position);
	}

	@Override
	public long getItemId(int position) {
		return mItems.indexOf(getItem(position));
	}
}